#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
	double price = 0;
	int month = 0, day = 0;
	int n = 0;
	scanf("%lf %d %d %d", &price, &month, &day, &n);
	if (11 == month)
	{
		price *= 0.7;
		switch (n)
		{
		case 1:
			price -= 50;
			break;
		case 0:
			break;
		}
		if (price < 0)
		{
			price = 0;
		}
	}
	else if (12 == month)
	{
		price *= 0.8;
		switch (n)
		{
		case 1:
			price -= 50;
			break;
		case 0:
			break;
		}
		if (price < 0)
		{
			price = 0;
		}
	}
	printf("%.2lf", price);
	return 0;
}